const express = require('express');
const mongo = require('../dataBase/users');
const router = express.Router();

router.get('/', (req, res) => {
    let userId = req.query.userId;
    mongo.Users.findOne({ userId: userId }, (err, docu) => {
        if (err) {
            res.send({ status: false });
            return
        }
        console.log('登陆用户:' + docu.name + ",ID为:" + docu.userId);
        var data = {
            userId: userId,
            status: true,
            avatarImg: docu.avatarImg,
            name: docu.name,
            friendList: docu.friendList
        }
        res.send(data);
    }).catch(err => {
        console.log(err);
        res.send({ status: false });
    })
})

module.exports = router;